//  this library.
import 'package:hktk_app/ienum/practice/ct_enum.dart';
import 'package:hktk_app/ienum/subject/paper_type_enum.dart';

/// 获取集合试题的做题记录归类模型
class ChapterTreeModel {
  String? id;
  String? name;
  int? parentId;
  int? categoryId;
  int? sort;
  bool? leaf;
  int? dc;
  int? ec;
  int? cc;
  String? time;
  CtEnum? recordsType;
  PaperTypeEnum? paperType;
  String? paperId;

  ChapterTreeModel({
    this.id,
    this.name,
    this.parentId,
    this.categoryId,
    this.sort,
    this.leaf,
    this.dc,
    this.ec,
    this.cc,
    this.time,
    this.recordsType,
    this.paperType,
    this.paperId,
  });

  ChapterTreeModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    parentId = json['parentId'];
    categoryId = json['categoryId'];
    sort = json['sort'];
    leaf = json['leaf'];
    dc = json['dc'];
    ec = json['ec'];
    cc = json['cc'];
    time = json['time'];
    if (json["recordsType"] != null) {
      recordsType = CtEnum.getTypeEnum(json['recordsType']);
    }
    if (json["paperType"] != null) {
      paperType = PaperTypeEnum.getTypeEnum(json['paperType']);
    }
    paperId = json['paperId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['name'] = name;
    data['parentId'] = parentId;
    data['categoryId'] = categoryId;
    data['sort'] = sort;
    data['leaf'] = leaf;
    data['dc'] = dc;
    data['ec'] = ec;
    data['cc'] = cc;
    data['time'] = time;
    if (recordsType != null) {
      data['recordsType'] = recordsType!.name;
    }
    if (paperType != null) {
      data['paperType'] = paperType!.name;
    }
    data['paperId'] = paperId;
    return data;
  }
}
